package com.tiantianfresh.view.controller;

import com.tiantianfresh.model.pojo.AJAXResult;
import com.tiantianfresh.model.pojo.User;
import com.tiantianfresh.view.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author FANGAO
 * @date 2021/11/26 - 下午 17:31
 */
@Controller
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ResponseBody
    @RequestMapping("/AjaxLogin")
    public Object AjaxLogin(User user){
        AJAXResult result = new AJAXResult();
        User userlog = loginService.queryUserLogin(user);
        if (userlog != null){
            result.setData(userlog);
            result.setSuccess(true);
        }else{
            result.setSuccess(false);
        }
        return result;
    }
}
